import CryptoJS from 'crypto-js'
import { defineStore } from 'pinia'

export const useAesStore = defineStore('aes', () => {
  var key = CryptoJS.enc.Utf8.parse('fkl200306241030=')
  const Decrypt = (data) => {
    var encryptedHexStr = CryptoJS.enc.Base64.parse(data)
    var encryptedBase64Str = CryptoJS.enc.Base64.stringify(encryptedHexStr)
    var decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, key, {
      mode: CryptoJS.mode.ECB,
      padding: CryptoJS.pad.Pkcs7
    })
    return decryptedData.toString(CryptoJS.enc.Utf8)
  }
  return { Decrypt }
})
